//
//  ZZFActionButtonView.m
//  YYUDemo
//
//  Created by zsp on 2017/3/17.
//  Copyright © 2017年 zsp. All rights reserved.
//

#import "ZZFActionButtonView.h"

#import <Masonry.h>

#import "ZZFConfigSet.h"
#import "UIColor+ZZFExtend.h"

@interface ZZFActionButtonView ()

@property(nonatomic, strong)UIButton *leftButton;
@property(nonatomic, strong)UIButton *middleButton;
@property(nonatomic, strong)UIButton *rightButton;

@end

@implementation ZZFActionButtonView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)init {
    if (self=[super init]) {
        [self configView];
    }
    return self;
}

- (void)buttonClickedAt:(UIButton*)button {
    NSInteger tag=button.tag;
    if (tag == 1001) {
        //left
        
    }else if (tag == 1002){
        //middle
        
    }else{
        //right
    }
}

- (void)configView {
    self.leftButton=[UIButton buttonWithType:UIButtonTypeCustom];
    self.leftButton.tag=1001;
    [self.leftButton addTarget:self action:@selector(buttonClickedAt:) forControlEvents:UIControlEventTouchUpInside];
    [self.leftButton setImage:[UIImage imageNamed:@"location"] forState:UIControlStateNormal];
    [self addSubview:self.leftButton];
    
    
    self.middleButton=[UIButton buttonWithType:UIButtonTypeCustom];
    self.middleButton.tag=1002;
    [self.middleButton addTarget:self action:@selector(buttonClickedAt:) forControlEvents:UIControlEventTouchUpInside];
    [self.middleButton setImage:[UIImage imageNamed:@"location"] forState:UIControlStateNormal];
    [self addSubview:self.middleButton];
    
    self.rightButton=[UIButton buttonWithType:UIButtonTypeCustom];
    self.rightButton.tag=1003;
    [self.rightButton addTarget:self action:@selector(buttonClickedAt:) forControlEvents:UIControlEventTouchUpInside];
    [self.rightButton setImage:[UIImage imageNamed:@"location"] forState:UIControlStateNormal];
    [self addSubview:self.rightButton];
    
    [self.leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self).offset(15);
        make.top.equalTo(self).offset(5);
        make.trailing.equalTo(self.middleButton.mas_leading).offset(-20);
        make.bottom.equalTo(self).offset(-5);
        make.width.equalTo(@[self.middleButton, self.rightButton]);
    }];
    
    [self.middleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.top.bottom.equalTo(self.leftButton);
    }];
    
    [self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.leading.equalTo(self.middleButton.mas_trailing).offset(20);
        make.trailing.equalTo(self).offset(-15);
        make.top.bottom.equalTo(self.leftButton);
    }];
    
}


@end
